package cn.xshi.sys.service.impl;
import java.util.List;
import java.util.Map;
import cn.xshi.sys.dao.SysKnowledgeDao;
import cn.xshi.sys.form.SysKnowledgeForm;
import cn.xshi.sys.model.SysKnowledge;
import cn.xshi.sys.service.SysKnowledgeService;
import org.springframework.stereotype.Service;
import cn.xshi.common.base.BaseService;
import cn.xshi.common.util.ExceptionUtil;
import javax.annotation.Resource;
/**
 * @Desc 平台知识内容
 * @Author 邓纯杰
 * @CreateTime 2012-12-12 12:12:12
 */
@Service
public class SysKnowledgeServiceImpl extends BaseService implements SysKnowledgeService {

	@Resource
	private SysKnowledgeDao sysKnowledgeDao;

	/**
	* 分页
	* @param sysKnowledgeForm
	* @return
	*/
	public List<SysKnowledge> getSysKnowledgeListByCondition(SysKnowledgeForm sysKnowledgeForm){
		try{
			return sysKnowledgeDao.getSysKnowledgeListByCondition(sysKnowledgeForm);
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
	}

	/**
	* 查询对象
	* @param id
	* @return
	*/
	public SysKnowledge getSysKnowledgeById(String id){
		try{
			return sysKnowledgeDao.getSysKnowledgeById(id);
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
	}

	/**
	* 添加
	* @param sysKnowledge
	* @return
	*/
	public int addSysKnowledge(SysKnowledge sysKnowledge){
		int i = 0;
		try {
			sysKnowledge.setCreateId(getCurrentAccountId());
			sysKnowledge.setCreateTime(getDate());
			i = sysKnowledgeDao.addSysKnowledge(sysKnowledge);
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
		return i;
	}

	/**
	* 修改
	* @param sysKnowledge
	* @return
	*/
	public int updateSysKnowledge(SysKnowledge sysKnowledge){
		int i = 0;
		try {
			sysKnowledge.setUpdateTime(getDate());
			sysKnowledge.setUpdateId(getCurrentAccountId());
			i = sysKnowledgeDao.updateSysKnowledge(sysKnowledge);
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
		return i;
	}

	/**
	* 删除
	* @param condition 
	* @return
	*/
	public int delSysKnowledge(Map<String,Object> condition){
		int i = 0;
		try {
			i = sysKnowledgeDao.delSysKnowledge(condition);
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
		return i;
	}

	/**
	 * 统计知识点数
	 * @param condition
	 * @return
	 */
	public int getSysKnowledgeCount(Map<String,Object> condition){
		return sysKnowledgeDao.getSysKnowledgeCount(condition);
	}
}
